package com.Maykk.Demo06;

import java.io.*;
import java.net.Socket;

/**
 * @ClassName: SendClient
 * @Description: TODO TCP 发送控制台输入内容
 * @Author: MaykkStar@163.com
 */
public class SendClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 9527);

        // 输入
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // 输出用于将键盘数据传入要发送给服务器的
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));

        // 键盘输入
        String line;
        while ((line = br.readLine()) != null) {
            if ("over".equals(line)) break;
            bw.write(line);
            bw.newLine(); // 每次输出一个换行
            bw.flush();
        }


        // 释放
        socket.close();
    }
}
